package com.heima.apis.article;

import com.heima.apis.article.fallback.ArticleClientFallback;
import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.article.pojos.ApArticle;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.StatisticsDto;
import com.heima.model.wemedia.dtos.WmCommentPageReqDTO;
import com.heima.model.wemedia.dtos.WmCommentLikeDTO;
import com.heima.model.wemedia.dtos.WmCommentListPageReqDTO;
import com.heima.model.wemedia.dtos.WmCommentUpdateStatusDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

/**
 * @author 陈辉
 * @data 2023 14:50
 */
@FeignClient(value = "leadnews-article", fallback = ArticleClientFallback.class)
@Component
public interface IArticleClient {

    /**
     * 根据时间范围统计点赞数量和收藏数量
     *
     * @param
     * @param
     * @param
     * @param beginDateTime
     * @param endDateTime
     * @return
     */
    @GetMapping("/api/v1/article/queryLikesAndConllections")
    ResponseResult queryLikesAndConllections(@RequestParam Integer authorId, @RequestParam LocalDateTime beginDateTime, @RequestParam LocalDateTime endDateTime);

    /**
     * 保存文章
     *
     * @param dto
     * @return
     */
    @PostMapping("/api/v1/article/save")
    public ResponseResult saveArticle(@RequestBody ArticleDto dto);

    /**
     * 获取文章
     *
     * @param articleId
     * @return
     */
    @GetMapping("/api/v1/article/{articleId}")
    ApArticle getArticle(@PathVariable("articleId") Long articleId);


    /**
     * 更新文章评论状态
     *
     * @param wmCommentUpdateStatusDTO
     * @return
     */
    @PostMapping("/api/v1/article/getCommentVo/updateStatus")
    ResponseResult updateCommentStatus(@RequestBody WmCommentUpdateStatusDTO wmCommentUpdateStatusDTO);


    /**
     * 查看文章评论列表
     *
     * @param wmCommentListPageReqDTO
     * @return
     */
    @PostMapping("/api/v1/article/comment/list")
    ResponseResult commentList(@RequestBody WmCommentListPageReqDTO wmCommentListPageReqDTO);

    /**
     * 自媒体端文章评论点赞
     *
     * @param wmCommentLikeDTO
     * @param authorId
     * @return
     */
    @PostMapping("/api/v1/article/comment/like")
    ResponseResult commentLike(@RequestBody WmCommentLikeDTO wmCommentLikeDTO, @RequestParam Integer authorId);

    /**
     * 根据文章id获取文章配置
     *
     * @param articleId
     * @return
     */
    @GetMapping("/api/v1/article/findArticleConfigByArticleId/{articleId}")
    ResponseResult findArticleConfigByArticleId(@PathVariable Long articleId);

    /**
     * 文章表中评论+1
     *
     * @param entryId
     */
    @GetMapping("/api/v1/article/comment/addOne/{entryId}")
    void addOneComment(@PathVariable("entryId") Long entryId);

    /**
     * 删除文章评论
     *
     * @param num
     * @param articleId
     */
    @GetMapping("/api/v1/article/comment/delete/{num}/{articleId}")
    void deleteCommentNum(@PathVariable("num") Integer num, @PathVariable("articleId") Long articleId);

    /**
     * 通过文章id获取文章信息
     *
     * @param articleId
     * @return
     */
    @GetMapping("/api/v1/article/comment/find/{articleId}")
    ApArticle findByArticleId(@PathVariable("articleId") Long articleId);


    /**
     * 根据用户id获取文章信息
     *
     * @param statisticsDto
     * @return
     */
    @PostMapping("/api/v1/article/statistics/newsPage")
    PageResponseResult newPage(@RequestBody StatisticsDto statisticsDto);


}
